home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / NextAnswers / 1413_textObject_runs.rtf < prev    next >
Text File  |  1993-11-08  |  1KB  |  41 lines

  1. {\rtf0\ansi{\fonttbl\f0\fnil Times-Roman;\f1\fmodern Courier;\f2\fmodern Ohlfs;}
  2. \paperw10860
  3. \paperh7040
  4. \margl120
  5. \margr120
  6. {\colortbl;\red0\green0\blue0;\red84\green84\blue84;\red83\green83\blue83;}
  7. \pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\f0\b0\i0\ulnone\fs28\fc0\cf0 Q: How do I get at the list of runs in a Text object, without subclassing the Text class?  Once I have them, how do I determine how many of them there are?\
  8. \
  9.  
  10. \fc1\cf1 A:\
  11.  
  12. \pard\tx960\tx1920\tx2880\tx3840\tx4800\tx5760\tx6720\tx7680\tx8640\tx9600\f1\fs24\fc1\cf1 \
  13.     #import <appkit/Text.h>\
  14. \
  15.     @interface Text(Private)\
  16.     - (int)nRuns;\
  17.     @end\
  18. \
  19.     @implementation Text(Private)\
  20.     -(int)nRuns\
  21.     \{\
  22.         return theRuns->chunk.used/sizeof(NXRun);\
  23.     \}\
  24.     @end\
  25. \
  26.     main ()\
  27.     \{\
  28.         id text = [[Text alloc]\
  29.         initFrame:NULL text:"Hello there" \\\
  30.             alignment:NX_LEFTALIGNED];\
  31.         printf("there are %d runs.\\n", [text nRuns]);\
  32.     \}\
  33.  
  34. \pard\tx1140\tx2300\tx3440\tx4600\tx5760\tx6900\tx8060\tx9200\tx10360\tx11520\f0\fs28\fc0\cf0 \
  35. \
  36. QA430\
  37. \
  38. Valid for 2.0, 3.0\
  39. \
  40.  
  41.